home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Demos / Component Software / FileFlex 2.0.3.sit / FileFlex 2.0.3 / FileFlex-Director / FileFlex Xtras / -Database Designer / 00014_makeItUp.ls < prev    next >
Encoding:
Text File  |  1997-08-18  |  4.6 KB  |  185 lines

  1. on mouseUp
  2.   -- process makeIt command -- create the DB
  3.   case (the frameLabel) of
  4.     "create":
  5.       FFCreateDatabase
  6.     "index":
  7.       FFCreateIndex
  8.   end case
  9. end
  10.  
  11. on mouseDown
  12.   set the castNum of sprite 17 to (the number of cast "makeItDown")
  13.   updateStage
  14.   repeat while the mouseDown is true 
  15.     -- wait for the mouse to go up
  16.   end repeat
  17.   set the castNum of sprite 17 to (the number of cast "makeItUp")
  18.   updateStage
  19. end mouseUP
  20.  
  21. on FFCreateDatabase
  22.   global baseSprite
  23.   cursor 4
  24.   if field "masterTypeList" = EMPTY then
  25.     cursor -1
  26.     BadCreateAlert
  27.     exit
  28.   end if
  29.   
  30.   put fileIO(mNew,"?write","") into theFileIO
  31.   if theFileIO < 0 then exit
  32.   put theFileIO(mFileName) into fspec
  33.   put theFileIO(mDelete) -- should dispose of the FileIO instance
  34.   
  35.   -- build the DB expression
  36.   put EMPTY into schema
  37.   repeat with i = 1 to the number of lines of field "masterTypeList"
  38.     put line i of field "masterNameList" & "," into theLine
  39.     case (line i of field "masterTypeList") of
  40.       "character":
  41.         put theLine & "C," into theLine
  42.         put theLine & string(line i of field "masterWidthList") into theLine
  43.       "numeric":
  44.         put theLine & "N," into theLine
  45.         put theLine & string(line i of field "masterWidthList") & "," into theLine
  46.         put theLine & string(line i of field "masterDecimalsList") into theLine
  47.       "logical":
  48.         put theLine & "L" into theLine
  49.       "date":
  50.         put theLine & "D" into theLine
  51.       "memo":
  52.         put theLine & "M" into theLine
  53.     end case
  54.     if schema <> EMPTY then put schema & RETURN into schema
  55.     put schema & theLine into schema
  56.   end repeat
  57.   
  58.   put DBOpenSession() into DBResult
  59.   if DBResult < 0 then
  60.     cursor -1
  61.     BadCreateAlert
  62.     exit
  63.   end if
  64.   
  65.   put DBCreate(fspec,the number of lines of schema,schema,"false") into DBResult
  66.   if DBResult < 0 then
  67.     cursor -1
  68.     BadCreateAlert
  69.     exit
  70.   end if
  71.   
  72.   put DBCloseSession() into DBResult
  73.   if DBResult < 0 then
  74.     cursor -1
  75.     BadCreateAlert
  76.     exit
  77.   end if  
  78.   
  79.   closeCreate
  80.   initCreate  -- do we go to another screen??
  81.   cursor -1
  82.   GoodCreateAlert -- We did it!!
  83. end FFCreateDatabase
  84.  
  85. on BadCreateAlert
  86.   global baseSprite
  87.   -- show the Good dialog
  88.   locShow baseSprite
  89.   set the castNum of sprite (baseSprite+1) to (the number of cast "DBCreateBad")
  90.   locShow baseSprite+1
  91.   set the castNum of sprite (baseSprite+3) to (the number of cast "UpOKDBCreateAlert")
  92.   locShow baseSprite+3
  93.   updateStage
  94. end BadCreateAlert
  95.  
  96. on GoodCreateAlert
  97.   global baseSprite
  98.   -- show the Good dialog
  99.   locShow baseSprite
  100.   set the castNum of sprite (baseSprite+1) to (the number of cast "DBCreateGood")
  101.   locShow baseSprite+1
  102.   set the castNum of sprite (baseSprite+3) to (the number of cast "UpOKDBCreateAlert")
  103.   locShow baseSprite+3
  104.   updateStage
  105. end GoodCreateAlert
  106.  
  107. on FFCreateIndex
  108.   global baseSprite, indexDBFile
  109.   
  110.   cursor 4
  111.   if field "indexExpr" = EMPTY then
  112.     cursor -1
  113.     BadIndexAlert
  114.     exit
  115.   end if
  116.   
  117.   put fileIO(mNew,"?write","") into theFileIO
  118.   if theFileIO < 0 then exit
  119.   put theFileIO(mFileName) into fspec
  120.   put theFileIO(mDelete) -- should dispose of the FileIO instance
  121.   
  122.   -- build the DB expression
  123.   put EMPTY into expr
  124.   repeat with i = 1 to the number of chars of field "indexExpr"
  125.     put char i of field "indexExpr" into theC
  126.     if theC <> RETURN and theC <> " " then
  127.       put expr & theC into expr
  128.     end if
  129.   end repeat
  130.   
  131.   put DBOpenSession() into DBResult
  132.   if DBResult < 0 then
  133.     cursor -1
  134.     BadIndexAlert
  135.     exit
  136.   end if
  137.   
  138.   put DBUse(indexDBFile) into DBResult
  139.   if DBResult < 0 then
  140.     cursor -1
  141.     BadIndexAlert
  142.     exit
  143.   end if
  144.   
  145.   put DBCreateIndex(fspec,expr,"0","0") into DBResult
  146.   if DBResult < 0 then
  147.     cursor -1
  148.     BadIndexAlert
  149.     exit
  150.   end if
  151.   
  152.   put DBCloseSession() into DBResult
  153.   if DBResult < 0 then
  154.     cursor -1
  155.     BadIndexAlert
  156.     exit
  157.   end if  
  158.   
  159.   put EMPTY into field "indexExpr"  -- do we go to another screen??
  160.   cursor -1
  161.   GoodIndexAlert -- We did it!!
  162. end FFCreateIndex
  163.  
  164. on BadIndexAlert
  165.   global baseSprite
  166.   -- show the Good dialog
  167.   locShow baseSprite
  168.   set the castNum of sprite (baseSprite+1) to (the number of cast "DBCreateIndexBad")
  169.   locShow baseSprite+1
  170.   set the castNum of sprite (baseSprite+3) to (the number of cast "UpOKDBCreateAlert")
  171.   locShow baseSprite+3
  172.   updateStage
  173. end BadIndexAlert
  174.  
  175. on GoodIndexAlert
  176.   global baseSprite
  177.   -- show the Good dialog
  178.   locShow baseSprite
  179.   set the castNum of sprite (baseSprite+1) to (the number of cast "DBCreateIndexGood")
  180.   locShow baseSprite+1
  181.   set the castNum of sprite (baseSprite+3) to (the number of cast "UpOKDBCreateAlert")
  182.   locShow baseSprite+3
  183.   updateStage
  184. end GoodIndexAlert
  185.